<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>

<body>
  <div id="app">
    <button @click="addPersonBefore">头部增加一个</button>
    <button @click="addPersonAfter">尾部增加一个</button>
    <ul>
      <li v-for="item in person" :key="item.id">
        姓名:{{item.name}} -- 年龄:{{item.age}}
      </li>
    </ul>
  </div>
  <script>
    Vue.config.productionTip = false;

    const vm = new Vue({
      el: "#app",
      data() {
        return {
          person: [{
              id: "001",
              name: "laowang",
              age: "19"
            },
            {
              id: "002",
              name: "xiaowang",
              age: "159"
            },
            {
              id: "003",
              name: "dawang",
              age: "119"
            },
          ]
        }
      },
      methods: {
        addPersonBefore() {
          this.person = [{
              id: Date.now(),
              name: "laoda",
              age: "000"
            },
            ...this.person
          ]
        },
        addPersonAfter() {
          this.person = [
            ...this.person,
            {
              id: Date.now(),
              name: "wangzhongwang",
              age: "123123"
            }
          ]
        }
      }
    })
  </script>
</body>

</html>